<?php
function ListAllLang($file)
{    
    if(!is_file($file))return array();
    
    @include($file);
    return $lang;
}

function SaveLang($alllang,$file,$namelang='lang')
{    
    $f  = @fopen($file,'w');
    if($f)
    {
        $data= '<'.'?php'."\n";
        foreach($alllang as $name=>$vl)
        {
            $vl    =  ($vl);
            $vl    = mysql_escape_string($vl);
            $data .='$'.$namelang.'[\''.$name.'\']= \''.$vl.'\';'."\n";
        }
        $data.="?".">";
        @fwrite($f,$data);
        @fclose($f);
    }
}

function backup()
{
    global $file,$language;
    
    $filebk = '../language/langall.txt';
    $alllang=ListAllLang($filebk);
    
    $langs  =ListAllLang($file);
    foreach($langs as $name=>$vl)
    {
       $alllang[$name] = $vl;
    }
    SaveLang($alllang,$filebk,'lang_'.$language);
}
?>